<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>缤格</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/member.css"/>
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/swiper.min.js"></script>
    <script type="text/javascript" src="../../script/mobile.js"></script>
    <script type="text/javascript">
        window['adaptive'].desinWidth = 750;
        window['adaptive'].baseFont = 28;
        window['adaptive'].maxWidth = 750;
        window['adaptive'].init();
    </script>
</head>
<body>
<section class="member_section bg-f5">

    <div class="match_box2 line_center flex_col c-fff"
         id="teamBg" style="background: url(../../image/match_bg.png) center no-repeat ;background-size:cover; ">

        <div id="header" style="height: 0.9rem; position: absolute; top: 0;left: 0; width: 100%; z-index: 99">
            <header class="member_header ">
                <div class="header-left">
                    <div tapmode onclick="comeBack();" class="nav-left">
                        <img class="icon-back" src="../../icon/icon-back-white.png"/>
                    </div>
                </div>
                <div class="header-right">
                    <div class="nav-right">
                        <div tapmode class="like_btn4 like_btn"></div>
                    </div>
                </div>
            </header>
        </div>

        <img src="../../icon/Icon.png" id="teamIcon" class="tm_tx" style=" width: auto;"/>
        <div class="f24 mt10" id="teamName"></div>
        <div class="f16" id="teamEnName"></div>
    </div>
    <ul class="userType_list3 bg-fff" style="padding:0 0.7rem;">
        <li tapmode class="on">简介</li>
        <li tapmode>成员</li>
        <li tapmode>历史荣誉</li>
    </ul>
    <div class="bg-fff pt30 pl30 pr30">
        <div class="page_box on">
            <h3>简介</h3>
            <p class="article_noeindent mt20" id="content"></p>
            <h3 class="mt30">基本资料</h3>
            <div class="pt20 pb20 bb c-999 line_center" style="align-items: flex-start"><span style="width: 1.3rem;">成立时间</span><span style="display: inline" class="ml20 c-333" id="beTime"></span></div>
            <div class="pt30 pb20 c-999 line_center" style="align-items: flex-start"><span style="width: 1.3rem;">所在地区</span><span style="display: inline" class="ml20 c-333" id="beAddress"></span></div>
            <h3 class="mt30">联系方式</h3>
            <div class="pt20 pb20 bb c-999 line_center" style="align-items: flex-start"><span style="width: 0.8rem;">电话</span><span style="display: inline" class="ml20 c-333" id="tel"></span></div>
            <div class="pt20 pb20 c-999 line_center" style="align-items: flex-start"><span style="width: 0.8rem;">邮箱</span><span style="display: inline" class="ml20 c-333" id="email"></span>
            </div>
        </div>
        <div class="page_box">
            <h3 id="guide_teacher">教练</h3>
            <ul class="coach_list" id="coach_list">
                <!--<li class="pt10 pb10 line_center">
                    <img src="../../image/coach.png" class="coach_img"/>
                    <span class="f26 b ml20">加雷卡</span>
                </li>
                <li class="pt10 pb10 line_center">
                    <img src="../../image/coach.png" class="coach_img"/>
                    <span class="f26 b ml20">加雷卡</span>
                </li>-->
            </ul>
            <div class="team_member mt10">
                <div class="tm_name"><span class="b f28">团队成员</span></div>
                <div class="tm_time"><span class="b f28">入学年份</span></div>
                <div class="tm_gps"><span class="b f28">位置</span></div>
            </div>
            <ul class="team_member_list" id="ordinary">
                <!--<li class="team_member bb pt30 pb20 f22 c-666">
                    <div class="tm_name single-ellipsis"><img src="../../image/coach.png" class="tm_img"/><span
                            class="ml20">迈克尔·乔丹</span></div>
                    <div class="tm_time">2019</div>
                    <div class="tm_gps">控球后卫</div>
                </li>
                <li class="team_member bb pt30 pb20 f22 c-666">
                    <div class="tm_name single-ellipsis"><img src="../../image/coach.png" class="tm_img"/><span
                            class="ml20">迈克尔·乔丹</span></div>
                    <div class="tm_time">2019</div>
                    <div class="tm_gps">大前锋</div>
                </li>-->
            </ul>
        </div>
        <div class="page_box">
            <ul class="team_ry_list" id="honor">
                <!--<li>
                    <div class="ry_img"><img src="../../image/jb.png"/></div>
                    <div class="ry_detail">
                        <div class="single-ellipsis">全国高校篮球比赛冠军</div>
                        <div class="single-ellipsis c-999 mt5">全国高校篮球是当前高校中最热门的体育项目</div>
                    </div>
                </li>
                <li>
                    <div class="ry_img"><img src="../../image/jb.png"/></div>
                    <div class="ry_detail">
                        <div class="single-ellipsis">全国高校篮球比赛冠军</div>
                        <div class="single-ellipsis c-999 mt5">全国高校篮球是当前高校中最热门的体育项目</div>
                    </div>
                </li>-->
            </ul>
        </div>

    </div>

</section>

</body>
</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
    var team_id = '';
    var type = 1;//类型：1球队简介 2成员列表 3历史荣誉
    apiready = function () {
        $api.fixStatusBar($api.dom('#header'));
        api.setStatusBarStyle({
            style: 'light', //设置APP状态栏字体色
            color: 'rgba(255,255,255,0)', //设置APP状态栏背景色
        });
        //setFixStatusBar(); //设置状态栏
        pop.loading();
        keybackListener()
        team_id = api.pageParam.team_id;
        // team_id = 4;

        getTeamDetail()

    }

    //获取球队信息
    function getTeamDetail() {
        var param = {
            token: $api.getStorage('token'),
            type: type,//类型：1球队简介 2成员列表 3历史荣誉
            team_id: team_id,//球队id
        }
        getAjax(Interface.team_details, param, function (res) {

            var data = res.data;

            if (isDefine(data)) {

                if (type == 1) {
                    //球队简介

                    //背景图
                    if(isDefine(data.background_path)){
                        $("#teamBg").css({background: 'url(' + ajaxUrl + data.background_path + ') center no-repeat'});
                    }
                    //队伍logo
                    $("#teamIcon").attr('src', ajaxUrl + data.path);
                    //队伍名称
                    $("#teamName").html(data.title);
                    //队伍英文名称
                    $("#teamEnName").html(data.english_title);
                    //队伍简介
                    $("#content").html(data.content);
                    //队伍成立时间
                    $("#beTime").html(data.found_time);
                    //队伍地址
                    $("#beAddress").html(data.address);
                    //队伍电话
                    $("#tel").html(data.tel);
                    //队伍邮箱
                    $("#email").html(data.email);

                    if(data.follow_status == 2){
                        $('.like_btn').removeClass('like_btn4').addClass('like_btn6')
                    }else {
                        $('.like_btn').removeClass('like_btn6').addClass('like_btn4')
                    }


                } else if (type == 2) {
                    //成员列表
                    var team = data.team;
                    if (isDefine(team)) {
                        //背景图
                        if(isDefine(team.background_path)){
                            $("#teamBg").css({background: 'url(' + ajaxUrl + team.background_path + ') center no-repeat'});
                        }
                        //队伍logo
                        $("#teamIcon").attr('src', ajaxUrl + team.path);
                        //队伍名称
                        $("#teamName").html(team.title);
                        //队伍英文名称
                        $("#teamEnName").html(team.english_title);

                        if(team.type == 3){
                            $("#guide_teacher").html('指导老师');
                        }
                    }

                    var coach = data.coach;
                    if (isDefine(coach)) {
                        var coach_list = ''
                        for (var i = 0; i < coach.length; i++) {
                            var info = coach[i];
                            var param = {"player_id": info.id, "status": 1}
                            coach_list += '<li class="pt15 pb15 line_center" tapmode onclick=\'commonUrl("team_member",' + jsonChange(param) + ')\'>' +
                                '            <img src="' + ajaxUrl + info.icon_path + '" class="coach_img"/>' +
                                '            <span class="f26 b ml20">' + info.name + '</span>' +
                                '        </li>'

                        }
                        $("#coach_list").html(coach_list)
                    }else {
                        if(team.type == 3){
                            $("#coach_list").html('<p class="t-c c-999 pt10 pb20">暂无指导老师信息</p>')
                        }else {
                            $("#coach_list").html('<p class="t-c c-999 pt10 pb20">暂无教练信息</p>')
                        }
                    }

                    var ordinary = data.ordinary;
                    if (isDefine(ordinary)) {
                        var ordinary_list = ''
                        for (var i = 0; i < ordinary.length; i++) {
                            var info = ordinary[i];
                            var param = {"player_id": info.id, "status": 2,"stype":ordinary.stype}
                            ordinary_list += '<li class="team_member bb pt30 pb20 f22 c-666" tapmode onclick=\'commonUrl("team_member",' + jsonChange(param) + ')\'>' +
                                '                    <div class="tm_name single-ellipsis">' +
                                '                       <h6 class="mr15 c-666">' + info.number + '</h6><img src="' + ajaxUrl + info.icon_path + '" class="tm_img"/><span class="ml20">' + info.name + '</span>' +
                                '                    </div>' +
                                '                    <div class="tm_time">' + info.entrance_time + '</div>' +
                                '                    <div class="tm_gps">' + info.position + '</div>' +
                                '                </li>';
                        }
                        $("#ordinary").html(ordinary_list)
                    }else {
                        $("#ordinary").html(noData)
                    }


                } else if (type == 3) {
                    //历史荣誉

                    var team = data.team;
                    if (isDefine(team)) {
                        //背景图
                        $("#teamBg").css({background: 'url(' + ajaxUrl + team.background_path + ') center no-repeat'});
                        //队伍logo
                        $("#teamIcon").attr('src', ajaxUrl + team.path);
                        //队伍名称
                        $("#teamName").html(team.title);
                        //队伍英文名称
                        $("#teamEnName").html(team.english_title);
                    }

                    var honor = data.honor;
                    if (isDefine(honor)) {
                        var honor_list = ''
                        for (var i = 0; i < honor.length; i++) {
                            var info = honor[i];
                            honor_list += '<li>' +
                                '              <div class="ry_img"><img src="' + ajaxUrl + info.icon_path + '"/></div>' +
                                '              <div class="ry_detail">' +
                                '                   <div class="single-ellipsis f28">' + info.title + '</div>' +
                                '                   <div class="single-ellipsis f24 c-999 mt5">' + info.introduction + '</div>' +
                                '              </div>' +
                                '          </li>';
                        }
                        console.log(honor_list)
                        $("#honor").html(honor_list)
                    } else {
                        $("#honor").html(noData)
                    }
                }


            }
            pop.close();
        }, function (error) {
            pop.notice(error.msg);
            pop.close();
        })
    }


    $(".userType_list3 li").click(function () {
        $(".userType_list3 li").removeClass("on");
        $(this).addClass("on");
        $(".page_box").removeClass("on");
        $(".page_box").eq($(this).index()).addClass("on");

        type = parseInt($(this).index()) + 1;
        getTeamDetail();
    })


    $(".like_btn").click(function () {
        if ($('.like_btn').hasClass('like_btn4')) {
            $('.like_btn').removeClass('like_btn4')
            $('.like_btn').addClass('like_btn6');
            set_team_follow(2)
        } else {
            $('.like_btn').removeClass('like_btn6');
            $('.like_btn').addClass('like_btn4');
            set_team_follow(1)
        }
    })
    
    function set_team_follow(type) {
        var param = {
            token: $api.getStorage('token'),
            type: type,//
            team_id: team_id,//球队id
        }
        getAjax(Interface.set_team_follow, param, function (res) {

            if(type == 1){
                pop.notice('已关注该球队')
            }else {
                pop.notice('已取消关注')
            }


        },function (error) {
            pop.notice(error.msg)
        })



    }


</script>
